<?php
namespace app\common\model;

use think\Model;

class QimenDunjiaLog extends Model
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'createtime_text',
        'sex_text',
        'type_text',
        'ju_model_text',
        'pan_model_text',
        'fei_pan_model_text',
        'zhen_text'
    ];
    
    // 性别文字
    public function getSexTextAttr($value, $data)
    {
        $list = [0 => '男', 1 => '女'];
        return isset($list[$data['sex']]) ? $list[$data['sex']] : '';
    }
    
    // 历类型文字
    public function getTypeTextAttr($value, $data)
    {
        $list = [0 => '农历', 1 => '公历'];
        return isset($list[$data['type']]) ? $list[$data['type']] : '';
    }
    
    // 起局方法文字
    public function getJuModelTextAttr($value, $data)
    {
        $list = [
            0 => '拆补法',
            1 => '置闰法',
            2 => '茅山道人法'
        ];
        return isset($list[$data['ju_model']]) ? $list[$data['ju_model']] : '';
    }
    
    // 盘类型文字
    public function getPanModelTextAttr($value, $data)
    {
        $list = [0 => '飞盘奇门', 1 => '转盘奇门'];
        return isset($list[$data['pan_model']]) ? $list[$data['pan_model']] : '';
    }
    
    // 飞盘排法文字
    public function getFeiPanModelTextAttr($value, $data)
    {
        $list = [1 => '全部顺排', 2 => '阴顺阳逆'];
        return isset($list[$data['fei_pan_model']]) ? $list[$data['fei_pan_model']] : '';
    }
    
    // 真太阳时文字
    public function getZhenTextAttr($value, $data)
    {
        $list = [1 => '考虑真太阳时', 2 => '不考虑真太阳时'];
        return isset($list[$data['zhen']]) ? $list[$data['zhen']] : '';
    }
    
    // 创建时间文字
    public function getCreatetimeTextAttr($value, $data)
    {
        return date('Y-m-d H:i:s', $data['createtime']);
    }
}